/**
  @creator: cilang
  @qq: 1019383856
  @bili: https://space.bilibili.com/433915419
  @gitee: https://gitee.com/OpencvLZG
  @github: https://github.com/OpencvLZG
  @since: 2023/12/2
  @desc: //TODO
**/

package middle

import "github.com/gin-gonic/gin"
import . "ginFlutterBolg/internal/util"

// CheckParamsNotNullMiddleware 检查是否有空参数
func CheckParamsNotNullMiddleware() func(c *gin.Context) {
	return func(c *gin.Context) {
		queryParams := c.Request.URL.Query()
		nullLabel := false
		for keys, value := range queryParams {
			for _, s := range value {
				if s == "" {
					ResponseStatusFail(c, 403, "参数不能为空", keys)
					c.Abort()
					nullLabel = true
					break
				}
			}
			if nullLabel {
				break
			}
		}
		c.Next()
	}
}
